﻿#include "GenericPlatform/InputManager.h"

#include <X11/keysym.h>
#include <X11/Xresource.h>

void InputManager::Init()
{
    s_KeyboardTypesMap[XK_Escape]         = KeyboardType::KEY_ESCAPE;
    s_KeyboardTypesMap[XK_Tab]            = KeyboardType::KEY_TAB;
    s_KeyboardTypesMap[XK_Shift_L]        = KeyboardType::KEY_LEFT_SHIFT;
    s_KeyboardTypesMap[XK_Shift_R]        = KeyboardType::KEY_RIGHT_SHIFT;
    s_KeyboardTypesMap[XK_Control_L]      = KeyboardType::KEY_LEFT_CONTROL;
    s_KeyboardTypesMap[XK_Control_R]      = KeyboardType::KEY_RIGHT_CONTROL;
    s_KeyboardTypesMap[XK_Alt_L]          = KeyboardType::KEY_LEFT_ALT;
    s_KeyboardTypesMap[XK_Alt_R]          = KeyboardType::KEY_RIGHT_ALT;
    s_KeyboardTypesMap[XK_Super_L]        = KeyboardType::KEY_LEFT_SUPER;
    s_KeyboardTypesMap[XK_Super_R]        = KeyboardType::KEY_RIGHT_SUPER;
    s_KeyboardTypesMap[XK_Menu]           = KeyboardType::KEY_MENU;
    s_KeyboardTypesMap[XK_Num_Lock]       = KeyboardType::KEY_NUM_LOCK;
    s_KeyboardTypesMap[XK_Caps_Lock]      = KeyboardType::KEY_CAPS_LOCK;
    s_KeyboardTypesMap[XK_Print]          = KeyboardType::KEY_PRINT_SCREEN;
    s_KeyboardTypesMap[XK_Scroll_Lock]    = KeyboardType::KEY_SCROLL_LOCK;
    s_KeyboardTypesMap[XK_Pause]          = KeyboardType::KEY_PAUSE;
    s_KeyboardTypesMap[XK_Delete]         = KeyboardType::KEY_DELETE;
    s_KeyboardTypesMap[XK_BackSpace]      = KeyboardType::KEY_BACKSPACE;
    s_KeyboardTypesMap[XK_Return]         = KeyboardType::KEY_ENTER;
    s_KeyboardTypesMap[XK_Home]           = KeyboardType::KEY_HOME;
    s_KeyboardTypesMap[XK_End]            = KeyboardType::KEY_END;
    s_KeyboardTypesMap[XK_Page_Up]        = KeyboardType::KEY_PAGE_UP;
    s_KeyboardTypesMap[XK_Page_Down]      = KeyboardType::KEY_PAGE_DOWN;
    s_KeyboardTypesMap[XK_Insert]         = KeyboardType::KEY_INSERT;
    s_KeyboardTypesMap[XK_Left]           = KeyboardType::KEY_LEFT;
    s_KeyboardTypesMap[XK_Right]          = KeyboardType::KEY_RIGHT;
    s_KeyboardTypesMap[XK_Down]           = KeyboardType::KEY_DOWN;
    s_KeyboardTypesMap[XK_Up]             = KeyboardType::KEY_UP;
    s_KeyboardTypesMap[XK_F1]             = KeyboardType::KEY_F1;
    s_KeyboardTypesMap[XK_F2]             = KeyboardType::KEY_F2;
    s_KeyboardTypesMap[XK_F3]             = KeyboardType::KEY_F3;
    s_KeyboardTypesMap[XK_F4]             = KeyboardType::KEY_F4;
    s_KeyboardTypesMap[XK_F5]             = KeyboardType::KEY_F5;
    s_KeyboardTypesMap[XK_F6]             = KeyboardType::KEY_F6;
    s_KeyboardTypesMap[XK_F7]             = KeyboardType::KEY_F7;
    s_KeyboardTypesMap[XK_F8]             = KeyboardType::KEY_F8;
    s_KeyboardTypesMap[XK_F9]             = KeyboardType::KEY_F9;
    s_KeyboardTypesMap[XK_F10]            = KeyboardType::KEY_F10;
    s_KeyboardTypesMap[XK_F11]            = KeyboardType::KEY_F11;
    s_KeyboardTypesMap[XK_F12]            = KeyboardType::KEY_F12;
    s_KeyboardTypesMap[XK_F13]            = KeyboardType::KEY_F13;
    s_KeyboardTypesMap[XK_F14]            = KeyboardType::KEY_F14;
    s_KeyboardTypesMap[XK_F15]            = KeyboardType::KEY_F15;
    s_KeyboardTypesMap[XK_F16]            = KeyboardType::KEY_F16;
    s_KeyboardTypesMap[XK_F17]            = KeyboardType::KEY_F17;
    s_KeyboardTypesMap[XK_F18]            = KeyboardType::KEY_F18;
    s_KeyboardTypesMap[XK_F19]            = KeyboardType::KEY_F19;
    s_KeyboardTypesMap[XK_F20]            = KeyboardType::KEY_F20;
    s_KeyboardTypesMap[XK_F21]            = KeyboardType::KEY_F21;
    s_KeyboardTypesMap[XK_F22]            = KeyboardType::KEY_F22;
    s_KeyboardTypesMap[XK_F23]            = KeyboardType::KEY_F23;
    s_KeyboardTypesMap[XK_F24]            = KeyboardType::KEY_F24;
    s_KeyboardTypesMap[XK_F25]            = KeyboardType::KEY_F25;

    s_KeyboardTypesMap[XK_KP_Divide]      = KeyboardType::KEY_KP_DIVIDE;
    s_KeyboardTypesMap[XK_KP_Multiply]    = KeyboardType::KEY_KP_MULTIPLY;
    s_KeyboardTypesMap[XK_KP_Subtract]    = KeyboardType::KEY_KP_SUBTRACT;
    s_KeyboardTypesMap[XK_KP_Add]         = KeyboardType::KEY_KP_ADD;

    s_KeyboardTypesMap[XK_KP_Insert]      = KeyboardType::KEY_KP_0;
    s_KeyboardTypesMap[XK_KP_End]         = KeyboardType::KEY_KP_1;
    s_KeyboardTypesMap[XK_KP_Down]        = KeyboardType::KEY_KP_2;
    s_KeyboardTypesMap[XK_KP_Page_Down]   = KeyboardType::KEY_KP_3;
    s_KeyboardTypesMap[XK_KP_Left]        = KeyboardType::KEY_KP_4;
    s_KeyboardTypesMap[XK_KP_Right]       = KeyboardType::KEY_KP_6;
    s_KeyboardTypesMap[XK_KP_Home]        = KeyboardType::KEY_KP_7;
    s_KeyboardTypesMap[XK_KP_Up]          = KeyboardType::KEY_KP_8;
    s_KeyboardTypesMap[XK_KP_Page_Up]     = KeyboardType::KEY_KP_9;
    s_KeyboardTypesMap[XK_KP_Delete]      = KeyboardType::KEY_KP_DECIMAL;
    s_KeyboardTypesMap[XK_KP_Equal]       = KeyboardType::KEY_KP_EQUAL;
    s_KeyboardTypesMap[XK_KP_Enter]       = KeyboardType::KEY_KP_ENTER;

    s_KeyboardTypesMap[XK_a]              = KeyboardType::KEY_A;
    s_KeyboardTypesMap[XK_b]              = KeyboardType::KEY_B;
    s_KeyboardTypesMap[XK_c]              = KeyboardType::KEY_C;
    s_KeyboardTypesMap[XK_d]              = KeyboardType::KEY_D;
    s_KeyboardTypesMap[XK_e]              = KeyboardType::KEY_E;
    s_KeyboardTypesMap[XK_f]              = KeyboardType::KEY_F;
    s_KeyboardTypesMap[XK_g]              = KeyboardType::KEY_G;
    s_KeyboardTypesMap[XK_h]              = KeyboardType::KEY_H;
    s_KeyboardTypesMap[XK_i]              = KeyboardType::KEY_I;
    s_KeyboardTypesMap[XK_j]              = KeyboardType::KEY_J;
    s_KeyboardTypesMap[XK_k]              = KeyboardType::KEY_K;
    s_KeyboardTypesMap[XK_l]              = KeyboardType::KEY_L;
    s_KeyboardTypesMap[XK_m]              = KeyboardType::KEY_M;
    s_KeyboardTypesMap[XK_n]              = KeyboardType::KEY_N;
    s_KeyboardTypesMap[XK_o]              = KeyboardType::KEY_O;
    s_KeyboardTypesMap[XK_p]              = KeyboardType::KEY_P;
    s_KeyboardTypesMap[XK_q]              = KeyboardType::KEY_Q;
    s_KeyboardTypesMap[XK_r]              = KeyboardType::KEY_R;
    s_KeyboardTypesMap[XK_s]              = KeyboardType::KEY_S;
    s_KeyboardTypesMap[XK_t]              = KeyboardType::KEY_T;
    s_KeyboardTypesMap[XK_u]              = KeyboardType::KEY_U;
    s_KeyboardTypesMap[XK_v]              = KeyboardType::KEY_V;
    s_KeyboardTypesMap[XK_w]              = KeyboardType::KEY_W;
    s_KeyboardTypesMap[XK_x]              = KeyboardType::KEY_X;
    s_KeyboardTypesMap[XK_y]              = KeyboardType::KEY_Y;
    s_KeyboardTypesMap[XK_z]              = KeyboardType::KEY_Z;
    s_KeyboardTypesMap[XK_1]              = KeyboardType::KEY_1;
    s_KeyboardTypesMap[XK_2]              = KeyboardType::KEY_2;
    s_KeyboardTypesMap[XK_3]              = KeyboardType::KEY_3;
    s_KeyboardTypesMap[XK_4]              = KeyboardType::KEY_4;
    s_KeyboardTypesMap[XK_5]              = KeyboardType::KEY_5;
    s_KeyboardTypesMap[XK_6]              = KeyboardType::KEY_6;
    s_KeyboardTypesMap[XK_7]              = KeyboardType::KEY_7;
    s_KeyboardTypesMap[XK_8]              = KeyboardType::KEY_8;
    s_KeyboardTypesMap[XK_9]              = KeyboardType::KEY_9;
    s_KeyboardTypesMap[XK_0]              = KeyboardType::KEY_0;
    s_KeyboardTypesMap[XK_space]          = KeyboardType::KEY_SPACE;
    s_KeyboardTypesMap[XK_minus]          = KeyboardType::KEY_MINUS;
    s_KeyboardTypesMap[XK_equal]          = KeyboardType::KEY_EQUAL;
    s_KeyboardTypesMap[XK_bracketleft]    = KeyboardType::KEY_LEFT_BRACKET;
    s_KeyboardTypesMap[XK_bracketright]   = KeyboardType::KEY_RIGHT_BRACKET;
    s_KeyboardTypesMap[XK_backslash]      = KeyboardType::KEY_BACKSLASH;
    s_KeyboardTypesMap[XK_semicolon]      = KeyboardType::KEY_SEMICOLON;
    s_KeyboardTypesMap[XK_apostrophe]     = KeyboardType::KEY_APOSTROPHE;
    s_KeyboardTypesMap[XK_grave]          = KeyboardType::KEY_GRAVE_ACCENT;
    s_KeyboardTypesMap[XK_comma]          = KeyboardType::KEY_COMMA;
    s_KeyboardTypesMap[XK_period]         = KeyboardType::KEY_PERIOD;
    s_KeyboardTypesMap[XK_slash]          = KeyboardType::KEY_SLASH;
    s_KeyboardTypesMap[XK_less]           = KeyboardType::KEY_WORLD_1;
}